#!/bin/bash
method="fptas"
for j in 4 10 15 20 22 25 27 30 32 35 37 40; do
    path="../../../../../../../data/task1/knap_$j.inst.dat.sol.$method"
    if [ -f $path ] ; then
        times=`cat $path | cut -d " " -f2`
        sum=0
        count=0

        for i in $times; do
          sum=`echo $i+$sum | bc`
          count=`echo "$count + 1" | bc`
        done

        average=`echo "scale=5;$sum / $count" | bc`

        echo "Soubor ${path##*/}:"
        echo "Vysledny cas(vsech instanci ($count)): $sum ms"
        echo "Prumerny cas: $average ms"
        echo
    else
        echo "Soubor ${path##*/} neexistuje!!!"
    fi
done